package com.mb.app.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.mb.app.dao.TbApiCallLogMapper;
import com.mb.app.domain.TbApiCallLog;
import com.mb.app.service.ITbApiCallLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 平台API调用记录  服务实现类
 * </p>
 *
 * @author zwl
 * @since 2019-05-28
 */
@Service
@Slf4j
public class TbApiCallLogServiceImpl extends ServiceImpl<TbApiCallLogMapper, TbApiCallLog> implements ITbApiCallLogService {


    /**
     * 用户日统计
     *
     * @param month
     * @return
     * @author dong
     * @date 2018-08-31 14:02:58
     */
    @Override
    public JSONObject dayStatistic(String month) {

        List<Map<String, Object>> rows = this.baseMapper.dayStatistic(month);

        // logger.info("rows------------->" + rows);

        JSONArray columns = new JSONArray();

        columns.add("date");
        columns.add("count");

        JSONObject data = new JSONObject();

        data.put("columns", columns);
        data.put("rows", rows);

        return data;
    }
}
